<template>
    <div >
        <div class="search-contain">
            <div class="search">
                <label class="label1">
                    <img src="/static/images/search.png" alt="">
                </label>
                <input v-model="getInput" @confirm="confirm" @focus="focus" @input="change" confirm-type="search" type="text" :placeholder="placeholder">
                <label v-if="getInput.length > 0" class="label2">
                    <img src="/static/images/quxiao.png" alt="">
                </label>
            </div>
            <div class="search-btn">
                <button>搜索</button>
            </div>
        </div>
        <div class="search-content">
            <div v-if="contentItems.length > 0" class="header-content">
                <p>历史搜索</p>
                <img src="/static/images/delete.png" alt="">
            </div>
            <div class="body-content">
                <div v-for="(item, index) in contentItems" :key="index" class="content-item">
                    <p>{{ item.content }}</p>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            placeholder: '输入商品名称',
            getInput: '',
            contentItems: [
                {
                    content: '哈哈哈'
                }
            ]
        }
    },
    methods: {
        focus() {
            this.$emit('focus');
            console.log(111);
        },
        change(e) {
            console.log(e.target.value.length);
        },
        confirm(e) {
            this.getInput = ''
        }
    }
}
</script>

<style scoped>
.search-contain {
    display: flex;
}
.search {
    margin: 20px 10px 0 15px;
    width: 70%;
    height: 30px;
    background: #d4cdcd;
    display:inline-flex;
    border-radius: 30px;
}
.label1 img {
    width: 18px;
    height: 20px;
    margin-left: 5px;
    margin-right: 5px;
    padding-top: 3px;
}
input {
    font-size: 16px;
    width: 75%;
    color: block;
}
.label2 img {
    width: 20px;
    height: 20px;
    float: right;
    padding-top: 5px;
}

.search-btn {
    height: 30px;
    width: 16%;
    border-radius: 30px;
    margin-top: 20px;
    padding-top: 1px;
}
.search-btn button {
    width: 100%;
    height: 100%;
    border-radius: 30px;
    background: #ea5149;
    font-size:16px;
    text-align:center;
    padding:0px;
    vertical-align:middle;
    line-height:22px;
    letter-spacing: 2px;
    margin:0px;
    padding-top: 5px;
    color: #ffffff;
}


.search-content {
    margin: 20px 30px 0 20px;
}
.header-content {
    display: flex;
}
.header-content p {
    width: 90%;
    font-size: 17px;
    letter-spacing: 1px;
    color: #252424;
}
.header-content img {
    width: 20px;
    height: 20px;
    float: right;
}


.body-content {
    display: flex;
    margin-top: 10px;
    justify-content: left;
    flex-wrap: wrap;
    align-items: center;
}
.content-item {
    height: 20px;
    background: #ddd7d7;
    border-radius: 20px;
    padding: 3px 5px;
    margin: 0 10px 10px 0;
}
.content-item p {
    height: 100%;
    font-size: 16px;
    color: #575252;
    letter-spacing: 1px;
}

</style>